import 'package:decimal/decimal.dart';

class SizeUtil {
  static getNetFileSizeDescription(int size) {
    String bytes = '';
    if (size >= 1024 * 1024 * 1024) {
      double i = (size / (1024.0 * 1024.0 * 1024.0));
      bytes = '${i.toStringAsFixed(2)}GB';
    } else if (size >= 1024 * 1024) {
      double i = (size / (1024.0 * 1024.0));
      bytes = '${i.toStringAsFixed(2)}MB';
    } else if (size >= 1024) {
      double i = (size / (1024.0));
      bytes = '${i.toStringAsFixed(2)}KB';
    } else if (size < 1024) {
      if (size <= 0) {
        bytes = ("0B");
      } else {
        bytes = '${size.toStringAsFixed(2)}B';
      }
    }
    return bytes;
  }
}
